# Figure S4: Conditional AMCE holding income constant

fig4a_dat = bind_rows(import(here("data","fig4a_inc_agree_dat.rds")) |> 
                        mutate(agree = "Agree"),
                      import(here("data","fig4a_inc_disagree_dat.rds")) |> 
                        mutate(agree = "Disagree")) |>
  invert_group()|> fix_healthcare()

fig4a_edu_agree = plot_conjoint(conjoint = fig4a_dat |> 
                                  filter(agree == "Agree"),
                                is_result = T,
                                lab = policies, 
                                weights = dta_grp$demog_weight[!is.na(dta_grp$edu_grp)],
                                use="for",
                                color_set=c("1"="grey","2"="black","3"="lightgreen","4"="darkgreen"),
                                title=NULL,
                                grouped_data=T) +
  labs(subtitle = "Agree with Policy", x = NULL, y = NULL)

fig4a_edu_disagree = plot_conjoint(conjoint = fig4a_dat |> 
                                     filter(agree == "Disagree"),
                                   is_result = T,
                                   lab = policies, 
                                   weights = dta_grp$demog_weight[!is.na(dta_grp$edu_grp)],
                                   use="against",
                                   color_set=c("1"="grey","2"="black","3"="lightgreen","4"="darkgreen"),
                                   title=NULL,
                                   grouped_data=T) +
  labs(subtitle = "Disagree with Policy", x = NULL, y = NULL)

fig4a_edu_pts = fig4a_edu_agree + fig4a_edu_disagree

print(fig4a_edu_pts)

ggsave(here("figures","appendix","figure_s4.png"), fig4a_edu_pts,
       dpi = 600, units = "in", width = 10, height = 9)

ccat("See 'figure_s4.png' for Figure S4 output")